package Day2025_04_10;

import java.util.Scanner;

public class Demo03 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String ss = sc.nextLine();
        char[] s = ss.toCharArray();
        int n = sc.nextInt();
        double ret = 0;
        int tmp = 0, temp = 0;
        for (int left = 0, right = 0; right < s.length; right++) {
            int len = right - left + 1;
            if (s[right] == 'C' || s[right] == 'G') tmp++;
            if (len == n) {
                double k = 1.0 * tmp / len;
                if (k > ret) {
                    ret = k;
                    temp = left;
                }
                if (s[left] == 'C' || s[left] == 'G') {
                    tmp--;
                }
                left++;
            }
        }
        System.out.println(ss.substring(temp, temp + n));
    }
}
